// 还款计算工具
import dayjs from 'dayjs'

export function calculatePaymentPlan(orderTime, leaseTerm, totalRent) {
  if (!orderTime || !leaseTerm || !totalRent) return []
  
  const monthlyPayment = totalRent / leaseTerm
  const plan = []
  
  for (let i = 1; i <= leaseTerm; i++) {
    const paymentDate = dayjs(orderTime).add(i, 'month').format('YYYY-MM-DD')
    const returnDate = dayjs(paymentDate).add(7, 'day').format('YYYY-MM-DD')
    
    plan.push({
      period: `第${i}期`,
      paymentDate,
      paymentAmount: monthlyPayment.toFixed(2),
      returnDate,
      returnAmount: monthlyPayment.toFixed(2),
      status: 'pending',
      remark: ''
    })
  }
  
  return plan
}

export function getStatusColor(status) {
  const colors = {
    paid: 'green',
    pending: 'orange',
    overdue: 'red',
    partial: 'blue'
  }
  return colors[status] || 'default'
}